<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Hugo 0.101.0">
    <title>Login</title>

    

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" rel="stylesheet">



    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
    </style>

    
    <!-- Custom styles for this template -->
    <link href="/css/login.css" rel="stylesheet">
  </head>
  <body class="text-center">
    
    <form class="form-signin">
      <!-- <img class="mb-4" src="../assets/brand/bootstrap-solid.svg" alt="" width="72" height="72"> -->
      <h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
      <input type="username" id="username" class="form-control" placeholder="username = admin" required autofocus>
      <input type="password" id="password" class="form-control" placeholder="password = admin" required>
      <div class="checkbox mb-3">
        <label>
          <input type="checkbox" value="remember-me"> Remember me
        </label>
      </div>
      <button class="btn btn-lg btn-primary btn-block" type="button" onclick="login()">Sign in</button>
      <p class="mt-5 mb-3 text-muted">&copy; MicroMQ by 刘天岳</p>
    </form>

    <script src="./js/jquery.min.js"></script>
    <script>
      function login() {
        $.ajax({
          type: "post",
          url: "/user/login",
          data: {
            username: $("#username").val(),
            password: $("#password").val()
          },
          success: function(result) {
            if(result != null && result.code === 200) {
              location.href = "manager.html";
            } else {
              if(result === null) {
                alert("result is null");
              } else {
                alert(result.message);
              }
            }
          }
        });
      }
    </script>
    
  </body>
</html>
